<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <title>企业员工工资管理-职称奖金列表</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
  <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" href="static/css/font.css">
  <link rel="stylesheet" href="static/css/xadmin.css">
  <script type="text/javascript" src="static/js/jquery-3.3.1.js"></script>
  <script type="text/javascript" src="static/lib/layui/layui.js"></script>
  <script type="text/javascript" src="static/js/xadmin.js"></script>
</head>

<body class="layui-anim layui-anim-up">

<div class="x-nav">
      <span class="layui-breadcrumb">
        <a >首页</a>
        <a >职称管理</a>
        <a>
          <cite>职称列表</cite></a>
      </span>
  <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
    <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body" id="container">
  <div class="layui-row">
    <div class="demoTable layui-col-md11 layui-form">
      职称：
      <div class="layui-inline">
        <input class="layui-input" name="id" id="demoReload" autocomplete="off">
      </div>
      <button class="layui-btn" data-type="reload">搜索</button>
      <button class="layui-btn" style=" margin-top: 0px;padding: 2px 10px 4px 10px" onclick="x_admin_show('添加','toPage.do?url=admin/rankBonus/rankBonusadd.html',600,400)"><i class="layui-icon"></i>添加</button>
      
    </div>
  
  </div>

  <div style="text-align: center">
    <table class="layui-table" lay-data="{height: 'full-160', cellMinWidth:80, url:'findRankBonusList.do', page:true, id:'idTest'}" lay-filter="demo">
      <thead>
      <tr>
        <th lay-data="{field:'rankName', width:300, fixed: true,align: 'center'}">职称</th>
        <th lay-data="{field:'rbBonus', minWidth:400,align: 'center'}">奖金</th>
        <th lay-data="{fixed: 'right', width:295, align:'center', toolbar: '#barDemo'}">操作</th>
      </tr>
      </thead>
    </table>
  </div>

</div>
<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script>
    layui.use('table', function(){
        var table = layui.table;

        //监听工具条
        table.on('tool(demo)', function(obj){
            var data = obj.data;
           if(obj.event === 'del'){
                layer.confirm('确定要删除吗', function(index){
                    $.ajax({
                        type:'post',
                        url:'rankBonusDelete.do',
                        data: {"id":data.rbId},
                        success:function(result){
                        	if(result.code==100){
                        		 layer.msg('删除成功!',{icon:1,time:4000});
                                 obj.del();
                        	}else{
                        		 layer.msg('存在员工依赖该职称！删除失败!',{icon:5,time:1000}); 
                        	}
                        },
                        error:function (data) {
                           alert("网络错误");
                        }
                    });
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){
                x_admin_show('编辑','toPage.do?url=admin/rankBonus/rankBonusEdit.html?rbId='+data.rbId+'&rankName='+data.rankName+'&rbBonus='+data.rbBonus, 600,400);
            }
        });

        var $ = layui.$, active = {
            reload: function(){
                var demoReload = $('#demoReload');
                // alert("asd");
                //执行重载
                table.reload('idTest', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                        rb_name: demoReload.val()
                    }
                });
            }
        };

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });



    });

</script>

</body>

</html>